package org.putrpctorest.resource.impl;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.putrpctorest.resource.Resources;

public class ResourcesImpl implements Resources{
    
    private String id;
    private String basePath;
    private Set<ResourceImpl> resources = new HashSet<ResourceImpl>();
    private Set<String> produces = new HashSet<String>();
    private Set<String> consumes = new HashSet<String>();
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getBasePath() {
        return basePath;
    }
    
    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }
    
    public Set<ResourceImpl> getResources() {
        return Collections.unmodifiableSet(resources);
    }
    
    public ResourceImpl getResource(String id) {
        for(ResourceImpl resource:resources) {
            if (resource.getId().equals(id)) {
                return resource;
            }
        }
        return null;
    }
    
    public void addResource(ResourceImpl resource) {
        resources.add(resource);
    }
    
    public void addResources(Set<ResourceImpl> resources) {
        this.resources.addAll(resources);
    }
    
    public void addConsumes(String consumes) {
        this.consumes.add(consumes);
    }
    
    public void addConsumes(Collection<String> consumes) {
        this.consumes.addAll(consumes);
    }
    
    public Set<String> getConsumes() {
        return Collections.unmodifiableSet(consumes);
    }
    
    public Set<String> getProduces() {
        return Collections.unmodifiableSet(produces);
    }

    public void addProduces(String produces) {
        this.produces.add(produces);
    }
    
    public void addProduces(Collection<String> produces) {
        this.produces.addAll(produces);
    }

}
